%% 函数或者脚本说明
%{
- --------------------------------------------------
* 文件名:RCS Angle Adjust
* 函数名:None
* 功 能:CST中， - theta到theta的扫描是通过改变phi的值扫描 - theta的
所以，这里判断，如果phi加了180°时，将theta变成负值
* 变量说明:GC1和GC2是结果，由实部和虚部两项构成
* 注意事项:
- --------------------------------------------------
%}
clc; clear;
NAME = "0.57";
filename = ".\RCS data\C\" + NAME + '.txt';
startRow = 3;
fileID = fopen(filename, 'r');
formatSpec = '%21f%21f%21f%[^\n\r]';
dataArray = textscan(fileID, formatSpec, 'Delimiter', '', 'WhiteSpace', '', 'TextType', 'string', 'HeaderLines', startRow - 1, 'ReturnOnError', false, 'EndOfLine', '\r\n');
fclose(fileID);
dataTable = table(dataArray{1:end - 1}, 'VariableNames', {'theta', 'phi', 'AbsRCS'});
clearvars filename startRow formatSpec fileID ans;
dataMat = table2array(dataTable);
Phi = 0; % 指定phi角
loc = (dataMat(:, 2) == Phi + 180) & ~(dataMat(:, 2) == Phi);
dataMat(loc, 1) = -dataMat(loc, 1);
dataTable = array2table(dataMat, 'VariableNames', {'theta', 'phi', 'AbsRCS'});

% writetable(dataTable,". \ RCS data \ " + NAME + '1.txt', 'Delimiter','\t')
currentPath = fileparts(mfilename('fullpath')); %获取m文件所在文件夹路径
writetable(dataTable, currentPath + "\RCS data\C\ " + NAME + '.xls')
disp("数据已经转换成功，使得\theta 的取值范围为-180到180");
clear;
